<?php use_helper('date'); ?>

<?php slot('title', sprintf("%s", $ktd_adventure->getTitle())) ?>
<?php slot('body-bg', ''); ?>
<?php slot('body-bg-head', NULL) ?>
<?php slot('body-bg-foot', NULL) ?>

<div class="cat"><img style="vertical-align: top" src="/images/mgen/icon/pastille.png"/><h1><?php echo $ktd_adventure->getKTDRegion()->getKTDArea()->getName() ?></h1><img style="vertical-align: top" src="/images/mgen/icon/pastille.png"/><h1><?php echo link_to($ktd_adventure->getKTDRegion()->getName(), "show_region",$ktd_adventure->getKTDRegion())  ?></h1><img style="vertical-align: top" src="/images/mgen/icon/pastille.png"/><h1><?php echo $ktd_adventure->getTitle() ?></h1></div>
<?php include_partial('pagination', array('pager' => $pager, 'ktd_adventure' => $ktd_adventure)) ?>
    <br/>
    <div class="span-8">
        <h3>Résumé</h3>
        <span class="italic">Commencée le <?php echo format_date($ktd_adventure->getStartedAt(), "p") ?> à <?php echo format_date($ktd_adventure->getStartedAt(), "H:mm") ?></span>
        <?php if($ktd_adventure->getSum() != NULL): ?>
        <p style="text-align:justify;">
            <?php echo KillTheDragon::shortenText(KTDCodeParser::getSingleton()->getParsedText($ktd_adventure->getSum(ESC_RAW)), 300); ?>
        <p>
        <a class="btn success" href="<?php echo url_for("show_adventure_sum", $ktd_adventure); ?>">Suite...</a>
        <?php else: ?>
        <p style="text-align:justify;">
            Aucun résumé n'a été proposé pour l'instant...
        <?php if($user_can_create_sum): ?>
            Soyez le premier à en proposer un !<br/>
            <a class="btn primary" href="<?php echo url_for("edit_adventure_sum", $ktd_adventure); ?>">Rédiger un résumé</a>
        <?php endif; ?>
        </p>
        <?php endif; ?>
    </div>
    <div class="slideToggle span-8">
        <h3>Les personnages présents sont </h3>
        <?php $i = 1 ?>
        <?php foreach($ktd_adventure->getActors() as $ktd_character) : ?>
            <?php echo link_to($ktd_character->getPseudo(), "show_fiche", $ktd_character); ?>
            <?php echo ($i < count($ktd_adventure->getActors())) ? ', ' : NULL ?>
            <?php $i++; ?>
        <?php endforeach; ?>
        <?php include_partial("global/social-buttons", array("route" => "show_adventure", "object" =>$ktd_adventure)); ?>
    </div>
<hr class="enluminure"/>
    <a href="<?php echo url_for("post_action", $ktd_adventure); ?>" class="btn primary">Répondre</a>
    <?php if($sf_user->isAuthenticated()): ?>
    <a class="btn" href="<?php echo url_for("watch", $ktd_adventure); ?>">
        <?php echo $sf_user->getGuardUser()->isWatching($ktd_adventure) ? "Remove Watch" : "Watch" ?> [<?php echo $ktd_adventure->countWatch() ?>]
    </a>
    <?php endif; ?>
<div>
    <?php foreach($ktd_actions as $i => $ktd_action): ?>
    <p id="<?php echo $ktd_action->getId() ?>" >
    <a href="#content">Remonter</a>
    <span class="daniel-font character-bubble top pull-1 left">
        <?php if($ktd_action->getKTDCharacter()->getAvatar() != NULL): ?>
            <img src="<?php echo $ktd_action->getKTDCharacter()->getAvatar() ?>" rel="<?php echo $ktd_action->getKTDCharacter()->getPseudo()?>" /><br/>
        <?php endif; ?>
        <?php echo link_to($ktd_action->getKTDCharacter()->getPseudo(), 'show_character', $ktd_action->getKTDCharacter()) ?>
    </span>
    </p>
    <p>
    <?php if($sf_user->hasRelPermission('edit_action', $ktd_action->getKTDCharacter()->getKTDPlayer())):?>
        <a href="<?php echo url_for("edit_action", $ktd_action) ?>" class="btn primary">Editer</a>
    <?php endif; ?>
     <?php if($sf_user->hasRelPermission('delete_action', $ktd_action->getKTDCharacter()->getKTDPlayer())):?>
        <a class="btn danger" href="<?php echo url_for('delete_action', $ktd_action) ?>">Supprimer</a>
     <?php endif; ?>
    </p>
    <div class="action-body">
            <?php echo $ktd_action->getParsedBody(ESC_RAW); ?>
    </div>
    <hr class="enluminure"/>
    <?php endforeach; ?>
    <a href="<?php echo url_for("post_action", $ktd_adventure); ?>" class="btn primary">Répondre</a>
<?php include_partial('pagination', array('pager' => $pager, 'ktd_adventure' => $ktd_adventure)) ?>
</div>
